

//
//  NSArray+hf.m
//  QiBaoTong
//
//  Created by 韩艳锋 on 2019/6/18.
//  Copyright © 2019 策驭. All rights reserved.
//

#import "NSArray+hf.h"
#import <UIKit/UIKit.h>
#import "NSDictionary+hf.h"

@implementation NSArray (hf)

- (NSArray*)map:(id(^)(id))map{
    NSMutableArray * arr = [NSMutableArray arrayWithCapacity:self.count];
    for (id obj in [self copy]) {
        id backObj = map(obj);
        if (backObj != nil) {
            [arr addObject:backObj];
        }
    }
    return arr;
}

- (NSMutableArray*)fliterNSNull {
    NSMutableArray * array = [NSMutableArray arrayWithCapacity:self.count];
    for (id item in self) {
        if ([item isKindOfClass:[NSNull class]]) {
            continue;
        } else if ([item isKindOfClass:[NSArray class]]) {
            [array addObject:[item fliterNSNull]];
        } else if ([item isKindOfClass:[NSDictionary class]]) {
            [array addObject:[item fliterNSNull]];
        } else {
            [array addObject:item];
        }
    }
    return array;
}
@end
